package com.example.module_service.adapter

import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.widget.TextView
import com.bw.polling.R
import com.bw.polling.entity.PollingEntity
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class XunluoAdapter : BaseQuickAdapter<PollingEntity,BaseViewHolder>(R.layout.item_dianwei) {
    override fun convert(holder: BaseViewHolder, item: PollingEntity) {
         holder.getView<TextView>(R.id.tv1).text = "项目名称/落址于的区域"
        val view = holder.getView<TextView>(R.id.tv2)
        view.setTextColor(Color.parseColor("#F2F2F2"))
        view.text = item.patrolType
        val drawable = GradientDrawable()
        drawable.cornerRadius = 15f
        view.background = drawable
        if (item.patrolType == "安防巡检"){
            drawable.setColor(Color.parseColor("#FF961E"))
        }else if(item.patrolType == "家居巡检"){
            drawable.setColor(Color.parseColor("#2691FC"))
        }else {
            drawable.setColor(Color.parseColor("#13D8A7"))
        }
        holder.getView<TextView>(R.id.tv3).text = "点位位置: ${item.pointLocation}"
        val t4 = holder.getView<TextView>(R.id.tv4)
        if (item.id % 2 == 1 ){
            t4.text = "点位状态：启用"
        }else{
            t4.text = "点位状态：未启用"
        }
    }
}